package com.openthree.common.oss;

import com.openthree.common.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 文件上传Factory
 * @author mhj
 * @email 254784163@qq.com
 * @date 2017-03-26 10:18
 */
@Component
public final class OSSFactory {

    private static CloudStorageConfig config;

    @Autowired
    private CloudStorageConfig config2;

    @PostConstruct
    public void beforeInit() {

        config = config2;
    }

    public static CloudStorageService build(){
        if(config.getType() == Constant.CloudService.QINIU.getValue()){
            return new QiniuCloudStorageService(config);
        }else if(config.getType() == Constant.CloudService.ALIYUN.getValue()){
            return new AliyunCloudStorageService(config);
        }else if(config.getType() == Constant.CloudService.QCLOUD.getValue()){
            return new QcloudCloudStorageService(config);
        }
        return null;
    }

}
